#ifndef PLAND_VIDEO_COMMON_HEADER
#define PLAND_VIDEO_COMMON_HEADER
#include <arpa/inet.h>

const int PNG_TAG_B = 1;
const int PNG_TAG_G = 2;
const int PNG_TAG_R = 3;

const int IMG_TAG_B = 4;
const int IMG_TAG_G = 5;
const int IMG_TAG_R = 6;

const int IMG_TAG_MAX = 100;
const int PNG_TAG_MAX = 3;

inline bool isImgTag(int tag)
{
    return (tag < IMG_TAG_MAX) & (tag > PNG_TAG_MAX);
}

inline uint32_t getPNGWidth(char* data)
{
    uint32_t* i = (uint32_t *)(data + 16);
    return htonl(*i);
}

inline unsigned int getPNGHeight(char* data)
{
    uint32_t* i = (uint32_t *)(data + 20);
    return htonl(*i);}

inline bool isPNG(char* data)
{
    char pngHeader[] = "\211PNG\r\n\032\n";
    for(int i = 0; i < 8; i++)
    {
        if(data[i] != pngHeader[i])
            return false;
    }
    return false;
}

#endif /* PLAND_VIDEO_COMMON_HEADER */
